#include <string>
#include <vector>
using namespace std;

class Robot {
   private:
    string pos;
    int x;
    int y;
    int width;
    int height;

   public:
    Robot(int width, int height) {
        this->pos = "East";
        this->x = 0;
        this->y = 0;
        this->width = width;
        this->height = height;
    }

    void step(int num) {
        num = num % (width * 2 + height * 2 - 4);
        if (pos == "East") {
            if (num <= width - 1 - x) {
                x = x + num;
                y = 0;
            } else if (num <= width - 1 - x + height - 1) {
                pos = "North";
                y = 0 + num - (width - 1 - x);
                x = width - 1;
            } else if (num <= width - 1 - x + height - 1 + width - 1) {
                pos = "West";
                x = width - 1 - (num - (width - 1 - x + height - 1));
                y = height - 1;
            } else if (num <=
                       width - 1 - x + height - 1 + width - 1 + height - 1) {
                pos = "South";
                y = height - 1 -
                    (num - (width - 1 - x + height - 1 + width - 1));
                x = 0;
            } else {
                y = 0;
                x = num-(width-1-x+height-1+width-1+height-1);
            }
        } else if (pos == "North") {
            if(num <=height-1-y){
                y = y+num;
                x = width-1;
            } else if(num <= height-1-y+width-1){
                x = width-1-(num-height-1-y);
                y = height-1;
                pos = "West";
            } else if(num <= height-1-y+width-1+height-1){
                y = height-1-(num-(height-1-y+width-1));
                x = 0;
                pos = "South";
            } else if(num <= height-1-y+width-1+height-1+width-1){
                x = num-(height-1-y+width-1+height-1);
                y = 0;
                pos = "East";
            } else{
                y = num-(height-1-y+width-1+height-1+width-1);
                x = width-1;
                pos = "North";
            }
        } else if (pos == "West") {
            if(num <=x){
                x = x-num;
                y=height-1;
            } else if(num<=x+height-1){
                pos = "South";
                y = height-1-(num-x);
                x = 0;
            } else if(num <=x+height-1+width-1){
                pos = "East";
                x = num-(x+height-1+width-1);
                y = 0;
            } else if(num <= x+height-1+width-1+height-1){
                y = num-(x+height-1+width-1);
                x = width-1;
                pos = "North";
            } else{
                x = width-1-(num-(x+height-+width-1+height-1));
                y = height-1;
                pos = "West";
            }
        } else {
            if(num <=y){
                pos = "South";
                x = 0;
                y = y-num;
            } else if(num <=y+width-1){
                pos = "East";
                x = num-y;
                y = 0;
            } else if(num <= y+width-1+height-1){
                pos = "North";
                y = num-(y+width-1);
                x = width-1;
            } else if(num <=y+width-1+height-1+width-1){
                pos = "West";
                x = width-1-(num-(y+(width-1)+(height-1)));
                y = height-1;
            } else{
                pos = "South";
                y = height-1-(num-(y+width-1+height-1+width-1));
                x = 0;
            }
        }
    }

    vector<int> getPos() {
        vector<int> pos;
        pos.push_back(this->x);
        pos.push_back(this->y);
        return pos;
    }

    string getDir() { return this->pos; }
};